package com.zxp.mall.member.web;


import com.alibaba.fastjson.JSON;
import com.zxp.mall.common.utils.R;
import com.zxp.mall.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

@Controller
public class MemberWebController {

    @Autowired
    OrderFeignService orderFeignService;

    @GetMapping("/memberOrder.html")
    public String memberOrder(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, Model model){
//        获取到支付宝回传的参数
//        验证签名 如果正确就去修改
        Map<String,Object> map = new HashMap<>();
        map.put("page", pageNum.toString());
        R r = orderFeignService.listWithItems(map);
        System.out.println(JSON.toJSONString(r));
        if(r.getCode() == 0) {
            model.addAttribute("orders", r);
        }
//        查出用户的所有订单的数据
        return "orderList";
    }

}
